using System;
using Microsoft.Health.Web;
using Microsoft.Health.PatientConnect;
using Microsoft.Health.Samples.PatientConnect.ContosoHealth.HealthVaultAdapter;

/// <summary>
/// Utility methods wrapper over the PatientConnect API
/// </summary>
public class PatientConnectUtilities
{
    Guid _applicationId = new Guid();
    /// <summary>
    /// Patient Connect Utility class
    /// </summary>
    /// <param name="AppId">Application Id</param>
    public PatientConnectUtilities(Guid appId)
    {
        _applicationId = appId;
    }

    /// <summary>
    /// Create patient in Health vault
    /// </summary>
    /// <param name="friendlyName">Patient's Name</param>
    /// <param name="securityQuestion">Security question</param>
    /// <param name="securityAnswer">Security Answer</param>
    /// <param name="applicationPatientId">Patient Application ID</param>
    /// <returns>Returns 20 digit identity code</returns>
    public string CreatePatient(string friendlyName, 
                                string securityQuestion, 
                                string securityAnswer, 
                                string applicationPatientId)
    {
        OfflineWebApplicationConnection _offlineConnection = HealthVaultConnectionManager.CreateConnection(_applicationId);
        string _identityCode = string.Empty;
        _identityCode = PatientConnection.Create(_offlineConnection, friendlyName, securityQuestion, securityAnswer, null, applicationPatientId);
        return _identityCode;
    }
}